var express = require('express');
var router = express.Router();
/* GET registers page. */
router.get('/', function(req, res, next) {
  res.render('register',{});
});
router.post('/',function(req,res,next){
	if(!req.users)
	return next(new Error('users is not exists'));
	var user = {
		username:req.body.username,
		pwd:req.body.pwd
	}
	console.log(user);
            if (user.username!=''&&user.pwd!='') {
            	req.users.insertOne(user);
            	     res.redirect('./logins');
            }
            
});
module.exports = router;
